package io.renren.modules.job.task;


import io.renren.modules.noc.entity.NocBeerTicketBusinessEntity;
import io.renren.modules.noc.service.NocBeerTicketBusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

@Component("beerBusinessTask")
public class BeerBusinessTask implements ITask {

    @Autowired
    private NocBeerTicketBusinessService nocBeerTicketBusinessService;
    @Override
    public void run(String params) {
        List<NocBeerTicketBusinessEntity> list = nocBeerTicketBusinessService.getNocBeerTicketBusinessEntity();
        for(NocBeerTicketBusinessEntity noc:list){
            if((System.currentTimeMillis()-noc.getRefreshTime().getTime())>30000){
                noc.setErcode(nocBeerTicketBusinessService.getNextErCodeBeer());
                noc.setRefreshTime(new Date());
                nocBeerTicketBusinessService.updateById(noc);

            }
        }
    }
}
